<template>
  <eip-modal
    :zIndex="1005"
    :visible="visible"
    title="查看历史版本"
    @close="cancel"
    width="600px"
  >
    <template slot="body">
      <a-spin :spinning="loading">
        <vxe-grid v-bind="gridOptions">
          <template #operate="{ row }">
            <a-tooltip title="查看">
              <label class="text-eip eip-cursor-pointer">查看</label>
            </a-tooltip>
            <a-divider type="vertical" />
            <a-tooltip title="恢复到此版本">
              <label class="text-red eip-cursor-pointer">恢复</label>
            </a-tooltip>
          </template>
        </vxe-grid>
      </a-spin>
    </template>
    <template slot="footer">
      <div class="flex justify-between align-center">
        <div></div>

        <a-space>
          <a-button @click="cancel"><a-icon type="close" />关闭</a-button>
        </a-space>
      </div>
    </template>
  </eip-modal>
</template>

<script>
import { findVersion } from "@/services/system/zerocode/automation/edit";
export default {
  name: "flowVersion",
  data() {
    return {
      loading: false,
      gridOptions: {
        border: true,
        height: 400,
        columns: [
          { field: "version", title: "版本号", width: 100, align: "center" },
          { field: "publicTime", title: "发布时间", width: 160 },
          { field: "updateUserName", title: "发布人", width: 100 },
          {
            title: "操作",
            field: "operate",
            align: "center",
            fixed: "right",
            slots: {
              default: "operate",
            },
          },
        ],
        data: [],
      },
    };
  },

  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    belongToId: String,
  },
  mounted() {
    this.find();
  },
  methods: {
    /**
     * 取消
     */
    cancel() {
      this.$emit("update:visible", false);
    },

    /**
     * 根据Id查找
     */
    async find() {
      let that = this;
      that.loading = true;
      findVersion({
        belongToId: this.belongToId,
      }).then(function (result) {
        that.gridOptions.data = result.data;
      });
      that.loading = false;
    },
  },
};
</script>
